package com.dahua.messagesyncsh.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.kafka.common.serialization.StringSerializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.config.KafkaListenerContainerFactory;
import org.springframework.kafka.core.*;
import org.springframework.kafka.listener.ContainerProperties;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

@Slf4j
@Component
public class KafkaConfig {
    private AdminClient adminClient;

    @Bean
    public AdminClient adminClient(KafkaAdmin kafkaAdmin) {
        log.info(kafkaAdmin.getConfigurationProperties().toString());
        adminClient = AdminClient.create(kafkaAdmin.getConfigurationProperties());
        return adminClient;
    }

    public void adminClose() {
        adminClient.close();
    }
}
